🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / app / src / main / java / com / geeksville / mesh / repository / datastore / RadioConfigRepository.kt
Displaying Raw • Download
app/src/main/java/com/geeksville/mesh/repository/datastore/RadioConfigRepository.kt ui_message_list (be3f882f) Text, 8.28 KB
T8b949e/*
* Copyright (c) 2025 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787com.geeksville.mesh.repository.datastore
Tff7b72import T7ee787com.geeksville.mesh.AppOnlyProtos.ChannelSet
Tff7b72import T7ee787com.geeksville.mesh.ChannelProtos.Channel
Tff7b72import T7ee787com.geeksville.mesh.ChannelProtos.ChannelSettings
Tff7b72import T7ee787com.geeksville.mesh.ClientOnlyProtos.DeviceProfile
Tff7b72import T7ee787com.geeksville.mesh.ConfigProtos.Config
Tff7b72import T7ee787com.geeksville.mesh.IMeshService
Tff7b72import T7ee787com.geeksville.mesh.LocalOnlyProtos.LocalConfig
Tff7b72import T7ee787com.geeksville.mesh.LocalOnlyProtos.LocalModuleConfig
Tff7b72import T7ee787com.geeksville.mesh.MeshProtos
Tff7b72import T7ee787com.geeksville.mesh.MeshProtos.DeviceMetadata
Tff7b72import T7ee787com.geeksville.mesh.MeshProtos.MeshPacket
Tff7b72import T7ee787com.geeksville.mesh.ModuleConfigProtos.ModuleConfig
Tff7b72import T7ee787com.geeksville.mesh.database.NodeRepository
Tff7b72import T7ee787com.geeksville.mesh.database.entity.MetadataEntity
Tff7b72import T7ee787com.geeksville.mesh.database.entity.MyNodeEntity
Tff7b72import T7ee787com.geeksville.mesh.database.entity.NodeEntity
Tff7b72import T7ee787com.geeksville.mesh.deviceProfile
Tff7b72import T7ee787com.geeksville.mesh.model.Node
Tff7b72import T7ee787com.geeksville.mesh.model.getChannelUrl
Tff7b72import T7ee787com.geeksville.mesh.service.ConnectionState
Tff7b72import T7ee787com.geeksville.mesh.service.ServiceAction
Tff7b72import T7ee787com.geeksville.mesh.service.ServiceRepository
Tff7b72import T7ee787kotlinx.coroutines.coroutineScope
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.SharedFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.StateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.combine
Tff7b72import T7ee787kotlinx.coroutines.flow.first
Tff7b72import T7ee787javax.inject.Inject
T8b949e/**
* Class responsible for radio configuration data. Combines access to [nodeDB], [ChannelSet], [LocalConfig] &
* [LocalModuleConfig].
*/
Tff7b72class T56d364RadioConfigRepository
Tf0883e@Inject
Tff7b72constructorTb4b4b4(
Tff7b72private Tff7b72val Te6edf3serviceRepositoryTb4b4b4: Te6edf3ServiceRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3nodeDBTb4b4b4: Te6edf3NodeRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3channelSetRepositoryTb4b4b4: Te6edf3ChannelSetRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3localConfigRepositoryTb4b4b4: Te6edf3LocalConfigRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3moduleConfigRepositoryTb4b4b4: Te6edf3ModuleConfigRepositoryTb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3meshServiceTb4b4b4: Te6edf3IMeshService?
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3meshService
T8b949e// Connection state to our radio device
Tff7b72val Te6edf3connectionState
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3connectionState
Tff7b72fun Td2a8ffsetConnectionStateTb4b4b4(Te6edf3stateTb4b4b4: Te6edf3ConnectionStateTb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3setConnectionStateTb4b4b4(Te6edf3stateTb4b4b4)
T8b949e/** Flow representing the unique userId of our node. */
Tff7b72val Te6edf3myIdTb4b4b4: Te6edf3StateFlowTff7b72<Tffa657String?Tff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3nodeDBTb4b4b4.Te6edf3myId
T8b949e/** Flow representing the [MyNodeEntity] database. */
Tff7b72val Te6edf3myNodeInfoTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3MyNodeEntity?Tff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3nodeDBTb4b4b4.Te6edf3myNodeInfo
T8b949e/** Flow representing the [Node] database. */
Tff7b72val Te6edf3nodeDBbyNumTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3MapTff7b72<Tffa657IntTb4b4b4, Te6edf3NodeTff7b72>Tff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3nodeDBTb4b4b4.Te6edf3nodeDBbyNum
Tff7b72fun Td2a8ffgetUserTb4b4b4(Te6edf3nodeNumTb4b4b4: Tffa657IntTb4b4b4) Tff7b72= Te6edf3nodeDBTb4b4b4.Te6edf3getUserTb4b4b4(Te6edf3nodeNumTb4b4b4)
Tff7b72suspend Tff7b72fun Td2a8ffgetNodeDBbyNumTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3nodeDBTb4b4b4.Te6edf3getNodeDBbyNumTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3firstTb4b4b4(Tb4b4b4)
Tff7b72suspend Tff7b72fun Td2a8ffupsertTb4b4b4(Te6edf3nodeTb4b4b4: Te6edf3NodeEntityTb4b4b4) Tff7b72= Te6edf3nodeDBTb4b4b4.Te6edf3upsertTb4b4b4(Te6edf3nodeTb4b4b4)
Tff7b72suspend Tff7b72fun Td2a8ffinstallMyNodeInfoTb4b4b4(Te6edf3miTb4b4b4: Te6edf3MyNodeEntityTb4b4b4) Tb4b4b4{
Te6edf3nodeDBTb4b4b4.Te6edf3installMyNodeInfoTb4b4b4(Te6edf3miTb4b4b4)
Tb4b4b4}
Tff7b72suspend Tff7b72fun Td2a8ffinstallNodeDbTb4b4b4(Te6edf3nodesTb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeEntityTff7b72>Tb4b4b4) Tb4b4b4{
Te6edf3nodeDBTb4b4b4.Te6edf3installNodeDbTb4b4b4(Te6edf3nodesTb4b4b4)
Tb4b4b4}
Tff7b72suspend Tff7b72fun Td2a8ffinsertMetadataTb4b4b4(Te6edf3fromNumTb4b4b4: Tffa657IntTb4b4b4, Te6edf3metadataTb4b4b4: Te6edf3DeviceMetadataTb4b4b4) Tb4b4b4{
Te6edf3nodeDBTb4b4b4.Te6edf3insertMetadataTb4b4b4(Te6edf3MetadataEntityTb4b4b4(Te6edf3fromNumTb4b4b4, Te6edf3metadataTb4b4b4)Tb4b4b4)
Tb4b4b4}
Tff7b72suspend Tff7b72fun Td2a8ffclearNodeDBTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3nodeDBTb4b4b4.Te6edf3clearNodeDBTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/** Flow representing the [ChannelSet] data store. */
Tff7b72val Te6edf3channelSetFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3ChannelSetTff7b72> Tff7b72= Te6edf3channelSetRepositoryTb4b4b4.Te6edf3channelSetFlow
T8b949e/** Clears the [ChannelSet] data in the data store. */
Tff7b72suspend Tff7b72fun Td2a8ffclearChannelSetTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3channelSetRepositoryTb4b4b4.Te6edf3clearChannelSetTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/** Replaces the [ChannelSettings] list with a new [settingsList]. */
Tff7b72suspend Tff7b72fun Td2a8ffreplaceAllSettingsTb4b4b4(Te6edf3settingsListTb4b4b4: Te6edf3ListTff7b72<Te6edf3ChannelSettingsTff7b72>Tb4b4b4) Tb4b4b4{
Te6edf3channelSetRepositoryTb4b4b4.Te6edf3clearSettingsTb4b4b4(Tb4b4b4)
Te6edf3channelSetRepositoryTb4b4b4.Te6edf3addAllSettingsTb4b4b4(Te6edf3settingsListTb4b4b4)
Tb4b4b4}
T8b949e/**
* Updates the [ChannelSettings] list with the provided channel and returns the index of the admin channel after the
* update (if not found, returns 0).
*
* @param channel The [Channel] provided.
* @return the index of the admin channel after the update (if not found, returns 0).
*/
Tff7b72suspend Tff7b72fun Td2a8ffupdateChannelSettingsTb4b4b4(Te6edf3channelTb4b4b4: Te6edf3ChannelTb4b4b4) Tff7b72= Te6edf3channelSetRepositoryTb4b4b4.Te6edf3updateChannelSettingsTb4b4b4(Te6edf3channelTb4b4b4)
T8b949e/** Flow representing the [LocalConfig] data store. */
Tff7b72val Te6edf3localConfigFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3LocalConfigTff7b72> Tff7b72= Te6edf3localConfigRepositoryTb4b4b4.Te6edf3localConfigFlow
T8b949e/** Clears the [LocalConfig] data in the data store. */
Tff7b72suspend Tff7b72fun Td2a8ffclearLocalConfigTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3localConfigRepositoryTb4b4b4.Te6edf3clearLocalConfigTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/**
* Updates [LocalConfig] from each [Config] oneOf.
*
* @param config The [Config] to be set.
*/
Tff7b72suspend Tff7b72fun Td2a8ffsetLocalConfigTb4b4b4(Te6edf3configTb4b4b4: Te6edf3ConfigTb4b4b4) Tb4b4b4{
Te6edf3localConfigRepositoryTb4b4b4.Te6edf3setLocalConfigTb4b4b4(Te6edf3configTb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3configTb4b4b4.Te6edf3hasLoraTb4b4b4(Tb4b4b4)Tb4b4b4) Te6edf3channelSetRepositoryTb4b4b4.Te6edf3setLoraConfigTb4b4b4(Te6edf3configTb4b4b4.Te6edf3loraTb4b4b4)
Tb4b4b4}
T8b949e/** Flow representing the [LocalModuleConfig] data store. */
Tff7b72val Te6edf3moduleConfigFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3LocalModuleConfigTff7b72> Tff7b72= Te6edf3moduleConfigRepositoryTb4b4b4.Te6edf3moduleConfigFlow
T8b949e/** Clears the [LocalModuleConfig] data in the data store. */
Tff7b72suspend Tff7b72fun Td2a8ffclearLocalModuleConfigTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3moduleConfigRepositoryTb4b4b4.Te6edf3clearLocalModuleConfigTb4b4b4(Tb4b4b4)
Tb4b4b4}
T8b949e/**
* Updates [LocalModuleConfig] from each [ModuleConfig] oneOf.
*
* @param config The [ModuleConfig] to be set.
*/
Tff7b72suspend Tff7b72fun Td2a8ffsetLocalModuleConfigTb4b4b4(Te6edf3configTb4b4b4: Te6edf3ModuleConfigTb4b4b4) Tb4b4b4{
Te6edf3moduleConfigRepositoryTb4b4b4.Te6edf3setLocalModuleConfigTb4b4b4(Te6edf3configTb4b4b4)
Tb4b4b4}
T8b949e/** Flow representing the combined [DeviceProfile] protobuf. */
Tff7b72val Te6edf3deviceProfileFlowTb4b4b4: Te6edf3FlowTff7b72<Te6edf3DeviceProfileTff7b72> Tff7b72=
Te6edf3combineTb4b4b4(Te6edf3nodeDBTb4b4b4.Te6edf3ourNodeInfoTb4b4b4, Te6edf3channelSetFlowTb4b4b4, Te6edf3localConfigFlowTb4b4b4, Te6edf3moduleConfigFlowTb4b4b4) Tb4b4b4{
Te6edf3nodeTb4b4b4,
Te6edf3channelsTb4b4b4,
Te6edf3localConfigTb4b4b4,
Te6edf3localModuleConfigTb4b4b4,
Tff7b72-Tff7b72>
Te6edf3deviceProfile Tb4b4b4{
Te6edf3nodeTff7b72?.Te6edf3userTff7b72?.Te6edf3let Tb4b4b4{
Te6edf3longName Tff7b72= Tffa657itTb4b4b4.Te6edf3longName
Te6edf3shortName Tff7b72= Tffa657itTb4b4b4.Te6edf3shortName
Tb4b4b4}
Te6edf3channelUrl Tff7b72= Te6edf3channelsTb4b4b4.Te6edf3getChannelUrlTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)
Te6edf3config Tff7b72= Te6edf3localConfig
Te6edf3moduleConfig Tff7b72= Te6edf3localModuleConfig
Tff7b72if Tb4b4b4(Te6edf3node Tff7b72!Tff7b72= Tff7b72null Tff7b72&Tff7b72& Te6edf3localConfigTb4b4b4.Te6edf3positionTb4b4b4.Te6edf3fixedPositionTb4b4b4) Tb4b4b4{
Te6edf3fixedPosition Tff7b72= Te6edf3nodeTb4b4b4.Te6edf3position
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tff7b72val Te6edf3clientNotification Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3clientNotification
Tff7b72fun Td2a8ffsetClientNotificationTb4b4b4(Te6edf3notificationTb4b4b4: Te6edf3MeshProtosTb4b4b4.Te6edf3ClientNotificationTff7b72?Tb4b4b4) Tb4b4b4{
Te6edf3serviceRepositoryTb4b4b4.Te6edf3setClientNotificationTb4b4b4(Te6edf3notificationTb4b4b4)
Tb4b4b4}
Tff7b72fun Td2a8ffclearClientNotificationTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3serviceRepositoryTb4b4b4.Te6edf3clearClientNotificationTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tff7b72val Te6edf3errorMessageTb4b4b4: Te6edf3StateFlowTff7b72<Tffa657String?Tff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3errorMessage
Tff7b72fun Td2a8ffsetErrorMessageTb4b4b4(Te6edf3textTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4{
Te6edf3serviceRepositoryTb4b4b4.Te6edf3setErrorMessageTb4b4b4(Te6edf3textTb4b4b4)
Tb4b4b4}
Tff7b72fun Td2a8ffclearErrorMessageTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3serviceRepositoryTb4b4b4.Te6edf3clearErrorMessageTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tff7b72fun Td2a8ffsetStatusMessageTb4b4b4(Te6edf3textTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4{
Te6edf3serviceRepositoryTb4b4b4.Te6edf3setStatusMessageTb4b4b4(Te6edf3textTb4b4b4)
Tb4b4b4}
Tff7b72val Te6edf3meshPacketFlowTb4b4b4: Te6edf3SharedFlowTff7b72<Te6edf3MeshPacketTff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3meshPacketFlow
Tff7b72suspend Tff7b72fun Td2a8ffemitMeshPacketTb4b4b4(Te6edf3packetTb4b4b4: Te6edf3MeshPacketTb4b4b4) Tff7b72= Te6edf3coroutineScope Tb4b4b4{ Te6edf3serviceRepositoryTb4b4b4.Te6edf3emitMeshPacketTb4b4b4(Te6edf3packetTb4b4b4) Tb4b4b4}
Tff7b72val Te6edf3serviceActionTb4b4b4: Te6edf3FlowTff7b72<Te6edf3ServiceActionTff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3serviceAction
Tff7b72suspend Tff7b72fun Td2a8ffonServiceActionTb4b4b4(Te6edf3actionTb4b4b4: Te6edf3ServiceActionTb4b4b4) Tff7b72= Te6edf3coroutineScope Tb4b4b4{ Te6edf3serviceRepositoryTb4b4b4.Te6edf3onServiceActionTb4b4b4(Te6edf3actionTb4b4b4) Tb4b4b4}
Tff7b72val Te6edf3tracerouteResponseTb4b4b4: Te6edf3StateFlowTff7b72<Tffa657String?Tff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3serviceRepositoryTb4b4b4.Te6edf3tracerouteResponse
Tff7b72fun Td2a8ffsetTracerouteResponseTb4b4b4(Te6edf3valueTb4b4b4: Tffa657String?Tb4b4b4) Tb4b4b4{
Te6edf3serviceRepositoryTb4b4b4.Te6edf3setTracerouteResponseTb4b4b4(Te6edf3valueTb4b4b4)
Tb4b4b4}
Tff7b72fun Td2a8ffclearTracerouteResponseTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3setTracerouteResponseTb4b4b4(Tff7b72nullTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.1 - Generated in 0.07s